Skip to content

Conversation

@anuraaga
Copy link
Collaborator

@anuraaga anuraaga commented Nov 11, 2025

I realized we need to support lifespan events to allow asyncio startup / shutdown logic for an app. The simplest way to expose this to users seemed to be accepting either a service or an async generator of a service in the application and resolve either within the lifespan events. We fallback to resolving on first request if the server doesn't support lifespan (this is basically just applying interceptors and shouldn't be a too-large first request penalty), one that notably doesn't is the httpx mock transport we recommend for unit tests.

Let me know any thoughts including the general approach.

Signed-off-by: Anuraag Agrawal <anuraaga@gmail.com>
Signed-off-by: Anuraag Agrawal <anuraaga@gmail.com>
Signed-off-by: Anuraag Agrawal <anuraaga@gmail.com>
Signed-off-by: Anuraag Agrawal <anuraaga@gmail.com>
Signed-off-by: Anuraag Agrawal <anuraaga@gmail.com>
Signed-off-by: Anuraag Agrawal <anuraaga@gmail.com>
Signed-off-by: Anuraag Agrawal <anuraaga@gmail.com>


class ConnectASGIApplication(ABC):
class ConnectASGIApplication(Generic[_SVC]):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this class has abstract methods, maybe it should also inherit from ABC?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, not sure why I thought Generic would imply that - fixed

Signed-off-by: Anuraag Agrawal <anuraaga@gmail.com>
@anuraaga
Copy link
Collaborator Author

anuraaga commented Nov 18, 2025

@i2y Can you give this another look? Also @stefanvanburen @spenczar in case this went under the radar. Thanks!

@i2y
Copy link
Contributor

i2y commented Nov 18, 2025

@i2y Can you give this another look? Also @stefanvanburen @spenczar in case this went under the radar. Thanks!

sorry, I just realized..

@anuraaga anuraaga merged commit 8613acb into connectrpc:main Nov 19, 2025
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants